<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <title>挂号添加页面</title>
    <link href="<%=basePath%>/css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<%=basePath%>/js/jquery.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>/js/rl.js"></script>
    <script type="text/javascript">
        $(function(){
            $.ajax({//查询科室
                url:"<%=basePath%>deptList",
                dataType : "json",
                //编码设置
                contentType : "application/json;charset=utf-8",
                success : function(data) {
                    for(var i=0;i<data.length;i++){
                        $("#departid").append("<option value='" + data[i].departid + "' >" + data[i].name + "</option>");
                    }
                },
                error:function(msg){
                    alert("后台服务器出错，请联系系统管理员");
                }
            });
            $("#departid").change(function(){//选择科室后查询医生
                var departid = $("#departid").val();
                $("#docid").empty();
                $.ajax({//查询科室
                    url: "<%=basePath%>doctorList?departid="+departid,
                    dataType: "json",
                    //编码设置
                    contentType: "application/json;charset=utf-8",
                    success: function (data) {
                        $("#docid").append("<option value='0' >-请选择-</option>");
                        for (var i = 0; i < data.length; i++) {
                            $("#docid").append("<option value='" + data[i].docid + "' >" + data[i].name + "</option>");
                        }
                    },
                    error: function (msg) {
                        alert("后台服务器出错，请联系系统管理员");
                    }
                })

            });
        })
        function goback(){
            window.location.href = "<%=basePath%>roListController";
        }
        function checkRoid(){
            $("#msg").text("");
            var roid = $("#roid").val();
            $.ajax({
                url:"<%=basePath%>checkRoid?roid="+roid,
                dataType : "json",
                //编码设置
                contentType : "application/json;charset=utf-8",
                success : function(data) {
                    if (data.msg != null) {
                        //  alert(data.msg);--onblur事件不要使用alert
                        $("#msg").append(data.msg);
                        $("#roid").val("");
                        $("#roid").focus();
                    }
                },
                error:function(){
                    alert("后台服务器出错，请联系系统管理员！");
                }
            })
        }
    </script>
    <style type="text/css">
        body {
            background:#FFF
        }
        #message{
            font-style: italic;
            font-size: larger;
            color:green;
        }
        #msg{
            /*font-size: large;*/
            color:red;
        }
    </style>
</head>
<body>
<form method="post" action="<%=basePath%>roAddController" method="post" name="ThisForm">
    <div id="contentWrap">
        <!--表格控件 -->
        <div id="widget table-widget">
            <div class="pageTitle">挂号添加</div>
            <label id="message">${success}</label>
            <div class="pageInfo">
                <table >
                    <tr>
                        <td width="20%" align="right">挂号ID</td>
                        <td width="20%"><input type="text" id="roid" name="roid" value="${ro.roid}" onblur="checkRoid()"/></td>
                        <label id="msg"></label>
                    </tr>
                    <tr>
                        <td width="20%" align="right">会员ID</td>
                        <td width="20%"><input type="text" id="memberid" name="memberid" value="${ro.memberid}"/></td>
                    </tr>
                    <tr>
                        <td align="right">科室</td>
                        <td >
                            <select style="width:150px;height:32px;" name="departid" id="departid">
                                <option value="">--请选择--</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">医生</td>
                        <td >
                            <select style="width:150px;height:32px;" name="docid" id="docid">
                                <option value="">--请选择--</option>
                            </select>
                        </td>
                        <td width="20%" align="right">挂号费用</td>
                        <td width="20%"><input type="text" id="ghfy" name="ghfy" value="${ro.ghfy}"/></td>
                        <td width="2%">元</td>
                    </tr>
                    <tr>
                        <td width="10%" align="right">挂号时间</td>
                        <td width="48%" ><input type="text" name="rotime" id="rotime" value="${ro.rotime}" onClick="SelectDate(this.name)"/></td>
                        <td width=""></td>
                        <td width=""></td>
                        <td width=""></td>
                    </tr>
                    <tr>
                        <td colspan="4" align="center">
                            <c:if test="${flag!='1'}">
                                <input type="submit" value="确定" />
                            </c:if>
                            &nbsp;
                            <input type="button" value="返回" onclick="goback()"/>
                        </td>
                    </tr>
                </table>
            </div>
        </div><!-- #widget -->
    </div>
</form>
</body>
</html>

